<?php
/**
 * 专题程序
 */
class controller_special extends controller_base {
	/**
	 * 专题列表
	 */
	public function action_index() {
		$methods = get_class_methods($this);
		$specials = array();
		foreach ($methods as $key => $item) {
			if(substr($item, 0, 7) === 'action_') {
				$specials[] = substr($item, 7);
			}
		}
		
		$this->assign('specials', $specials);
	}
	
	/**
	 * 我的2010
	 */
	public function action_2010end() {
		
	}
	
	/**
	 * 数据 
	 */
	public function action_data() {
		$db = new common_mysql();
		$tables = $db->fetch_query('SHOW TABLES');
		$count_all = 0;
		$table_count = array();
		
		foreach ($tables as $item) {
			$table_name = current($item);
			$result = $db->fetch_query("SELECT COUNT(*) total FROM `$table_name`");
			
			$table_count[$table_name] = $result[0]['total'];
			$count_all += $result[0]['total'];
		}
		
		// 整理饼图中的data与label
		$data = array();
		$label = array();
		arsort($table_count);
		$i = 1;
		foreach ($table_count as $key => $value) {
			if($i > 7) {
				isset($data[7]) || $data[7] = 0;
				$data[7] += $value;
				$label[7] = 'other - '.$data[7];
			} else {
				$data[] = $value;
				$label[] = $key.' - '.$value;
			}
			$i++;
		}
		
		$this->assign('count_all', $count_all);
		$this->assign('data', $data);
		$this->assign('label', $label);
	}

	public function action_59word() {
		$model_note = new model_note();

		$start_time = strtotime('2011-05-09');
		$end_time = strtotime(date('Y-m-d')) + 86400;


		$where = "create_time >= $start_time AND create_time <= $end_time AND content LIKE '#背单词%'";

		$result = $model_note->daily_notes($where);

		$this->assign('result', $result);
	}

    public function action_intencent() {
    
    }
	
}
